home *** CD-ROM | disk | FTP | other *** search
/ PC Elektro 3 / PC-Elektro-3-cd1.bin / KBan 2.0 / KBANSRC.LZH / SRC / PROG / COMMON / SLIST.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-23  |  554 b   |  31 lines

  1. #ifndef _SLIST2_H_
  2. #define _SLIST2_H_
  3.  
  4. #include <list>
  5.  
  6. #define TRAVERSE(list, i) \
  7.   for(i = (list).begin(); i != (list).end(); i++)
  8.  
  9. template<class T>
  10. class extended_list : public std::list<T> {
  11. public:
  12.   void clear(void) {
  13.     erase(begin(), end());
  14.   }
  15.   bool delete_one(T* target)
  16.   {
  17.     bool flag = false;
  18.     iterator i;
  19.     TRAVERSE(*this, i) {
  20.       if(&*i == target) {
  21.         flag = true;
  22.         iterator current_i = i--;
  23.         erase(current_i);
  24.       }
  25.     }
  26.     return flag;
  27.   }
  28. };
  29.  
  30. #endif /* _SLIST2_H_ */
  31.